package media;

import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import junit.framework.Test;

// 视频播放
public class MediaViewDemo {
	private static String url;
	private static Media media;
	private static MediaPlayer mp;
	private static MediaView mv;	// 节点
	
	private MediaViewDemo() {
		
	}
	
	// 返回媒体视图
	public static MediaView getMediaView(String name) {
		url = Test.class.getResource("/music/" + name).toString(); 
		media = new Media(url);   		
		mp = new MediaPlayer(media); 
		mv = new MediaView(mp);
		mv.setSmooth(true);		// 使视频更流畅(还可以设置很多东西,节点)
		mp.play();		// 由MediaPlayer控制状态
		return mv;
	}
}
